Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store last loaded playlist #2101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcorporation
Copy link
Member

Stores the last loaded playlist uri in the queue struct. Last loaded playlist is set on load command and cleared with the clear command. The last loaded playlist is printed in the status command and saved / restored from the partition state file.

Resolves issue #938

@@ -102,6 +102,9 @@ struct playlist {
[[gnu::pure]]
int GetNextPosition() const noexcept;

const std::string getLastLoadedPlaylist() const noexcept;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad method name, but the worst thing is that this allocates a copy of the string on the heap.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to starting uppercase and converted to std::string_view. I hope this is correct!

@@ -270,6 +270,7 @@ Queue::Clear() noexcept
}

length = 0;
last_loaded_playlist = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a smell - last_loaded_playlist.clear(); is better and faster

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced

@@ -85,6 +85,9 @@ struct Queue {
/** play back songs in random order? */
bool random = false;

/** Last loaded playlist */
std::string last_loaded_playlist = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initializer has no effect (except for adding runtime overhead)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Stores the last loaded playlist uri in the queue struct.
Last loaded playlist is set on load command and cleared with the clear command.
The last loaded playlist is printed in the status command and saved / restored from the partition state file.

Resolves issue MusicPlayerDaemon#938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants